from pymongo import MongoClient
import statistics
client = MongoClient(port=27017)
db=client['tiktok']
collist=['homeimprovement','gamingtiktok','gamergoals','imbusyrightnow','90saesthetic','feelinggood','foodie','albumcover','groupchat','beautyhack','autismawareness','guitartok','gettheretogether','hyperfixated'
    ,'greenscreenscan','mobilegame','foodontiktok','ecohacks','defrosting','fitnessroutine','galentinesday','inspirationalquotes','fetapasta','happyholi','colorblast','blackandproud','dinnerparty','cleaningtiktok'
    ,'emophase','mifamilia']
for col in db.list_collection_names():
#for col in collist:
    print(col)
    for obj in db[col].find():
        if len(obj['video_feature']['audio']['yamnet'])>0 and 'var_yamnet' not in obj['video_feature']['editing'].keys():
            yv=statistics.variance(obj['video_feature']['audio']['yamnet'])
            db[col].update_one({'_id':obj['_id']},{'$set':{'video_feature.editing.var_yamnet':yv}})